package com.woniu.communitymanagement.controller;

import com.woniu.communitymanagement.entity.Building;
import com.woniu.communitymanagement.entity.HttpResult;
import com.woniu.communitymanagement.entity.vo.BuildingVO;
import com.woniu.communitymanagement.service.BuildingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/building")
public class BuildingController {
    @Autowired
    private BuildingService buildingService;
    @RequestMapping("/add")
    @CrossOrigin(origins = "*")
    public HttpResult addBuilding(@RequestBody BuildingVO building){
        return buildingService.insertBuilding(building);
    }
    @RequestMapping("/delete")
    @CrossOrigin(origins = "*")
    public HttpResult deleteById(Integer id){
        return buildingService.deleteById(id);
    }
    @RequestMapping("/update")
    @CrossOrigin(origins = "*")
    public HttpResult updateById(@RequestBody Building building){
        return buildingService.updateBuildingById(building);
    }

    @RequestMapping("/selectone")
    @CrossOrigin(origins = "*")
    public HttpResult selectBuildingById(Integer id){
        return buildingService.selectBuildingByid(id);
    }
    @RequestMapping("/list")
    @CrossOrigin(origins = "*")
    public HttpResult list(String numbers,Integer pageIndex,Integer pageSize){
        return buildingService.selectAll(numbers,pageIndex,pageSize);
    }
    @RequestMapping("/all")
    @CrossOrigin(origins = "*")
    public HttpResult selectAll(){
        return buildingService.listAll();
    }


}
